<template>
  <NavBar showBack :title="articleInfo?.title"></NavBar>
  <rich-text style="white-space: pre-wrap" :nodes="formatRichText(articleInfo?.content || '')"></rich-text>
</template>

<script setup>
import { onMounted, ref } from "vue"
import { router } from "@/path/router";
import service from "@/path/service"
import { formatRichText } from "@/path/until";
import NavBar from "@/components/ui/nav-bar"
const articleInfo = ref({})
onMounted(() => {
  const routerData = router.getData()
  if (!routerData?.richTextId) return
  let params = {
    id: routerData?.richTextId
  }
  if (routerData?.type === "articlecategory") {
    params = {
      categoryId: routerData?.richTextId
    }
  }
  service.get("api/ycg/home/article", params).then((res) => {
    articleInfo.value = res
  })
})
</script>

<style lang="less" scoped>
@import url(./index.less);
</style>
